home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / wasm223.zip / VIDEO4.ASM < prev    next >
Assembly Source File  |  1993-05-04  |  5KB  |  171 lines

  1. ;******************************************;
  2. ; WASM Video Module, Cursor Routines       ;
  3. ; By Eric Tauck                            ;
  4. ;                                          ;
  5. ; Defines:                                 ;
  6. ;                                          ;
  7. ;   CurAct  activate/deactive cursor       ;
  8. ;   CurGet  return the cursor on/off state ;
  9. ;   CurSet  turn the cursor on/off         ;
  10. ;   CurCol  return current column          ;
  11. ;   CurRow  return current row             ;
  12. ;   CurPos  return current column and row  ;
  13. ;   CurMov  move cursor to location        ;
  14. ;   CurAdv  advance the cursor             ;
  15. ;                                          ;
  16. ; Requires:                                ;
  17. ;                                          ;
  18. ;   VIDEO1.ASM                             ;
  19. ;******************************************;
  20.  
  21.         jmp     _video4_end
  22.  
  23. ;========================================
  24. ; Activate or deactive cursor.
  25. ;
  26. ; In: AL= zero if deactivate, otherwise
  27. ;     activate.
  28. ;
  29. ; Out: AL= original state.
  30.  
  31. CurAct  PROC    NEAR
  32.         mov     ah, _vid_flags          ;load flags
  33.         push    ax                      ;save for return
  34.         and     _vid_flags, NOT _vid_CACT ;clear bit
  35.         or      al, al                  ;check if deactivate
  36.         jz      _cract1
  37.         test    ah, _vid_CACT           ;check if already active
  38.         jnz     _cract1
  39.         or      _vid_flags, _vid_CACT   ;set bit
  40.         mov     ax, _vid_colrow         ;current location
  41.         call    CurMov                  ;set physical cursor
  42. _cract1 pop     ax                      ;original flags
  43.         mov     al, ah
  44.         and     al, _vid_CACT           ;return bit
  45.         ret
  46.         ENDP
  47.  
  48. ;========================================
  49. ; Return the cursor on/off state.
  50. ;
  51. ; Out: AL= cursor on/off state.
  52.  
  53. CurGet  PROC    NEAR
  54.         mov     al, _vid_flags  ;load flags
  55.         and     al, _vid_CVIS   ;mask relevant bit
  56.         ret
  57.         ENDP
  58.  
  59. ;========================================
  60. ; Set the cursor on or off.
  61. ;
  62. ; In: AL= non-zero if set visible,
  63. ;     otherwise set invisible.
  64. ;
  65. ; Out: AL= original state.
  66.  
  67. CurSet  PROC    NEAR
  68.         mov     ah, _vid_flags          ;load flags
  69.         push    ax                      ;save for return
  70.         or      al, al                  ;check if turn on or off
  71.         jnz     _crset1                 ;jump if turn on
  72.  
  73. ;--- cursor off
  74.  
  75.         test    ah, _vid_CVIS           ;check if already off
  76.         jz      _crset2
  77.         mov     ah, 1                   ;set cursor function
  78.         mov     cx, _vid_coff           ;off scan pattern
  79.         int     10H                     ;execute
  80.         and     _vid_flags, NOT _vid_CVIS ;clear flag
  81.         jmps    _crset2
  82.  
  83. ;--- cursor on
  84.  
  85. _crset1 test    ah, _vid_CVIS           ;check if already on
  86.         jnz     _crset2
  87.         mov     ah, 1                   ;set cursor function
  88.         mov     cx, _vid_con            ;on scan pattern
  89.         int     10H                     ;execute
  90.         or      _vid_flags, _vid_CVIS   ;set flag
  91.         mov     ax, _vid_colrow         ;current location
  92.         call    CurMov                  ;position cursor, sets physical cursor
  93.  
  94. _crset2 pop     ax
  95.         mov     al, ah
  96.         and     al, _vid_CVIS
  97.         ret
  98.         ENDP
  99.  
  100. ;========================================
  101. ; Return the cursor column.
  102. ;
  103. ; Out: AL= column.
  104.  
  105. CurCol  PROC    NEAR
  106.         mov     al, _vid_col    ;return column
  107.         ret
  108.         ENDP
  109.  
  110. ;========================================
  111. ; Return the cursor row.
  112. ;
  113. ; Out: AL= row.
  114.  
  115. CurRow  PROC    NEAR
  116.         mov     al, _vid_row    ;return row
  117.         ret
  118.         ENDP
  119.  
  120. ;========================================
  121. ; Return the cursor position (row and
  122. ; column).
  123. ;
  124. ; Out: AL= column; AH= row.
  125.  
  126. CurPos  PROC    NEAR
  127.         mov     ax, _vid_colrow ;return column and row
  128.         ret
  129.         ENDP
  130.  
  131. ;========================================
  132. ; Move the cursor.
  133. ;
  134. ; In: AL= column; AH= row.
  135.  
  136. CurMov  PROC    NEAR
  137.         mov     _vid_curadv, 0          ;zero advance count
  138.  
  139. ;--- save location and determine address for next write
  140.  
  141.         mov     _vid_colrow, ax         ;save column and row
  142.         call    _vid_setaddr            ;set write address
  143.  
  144. ;--- move physical cursor if visible and active
  145.  
  146.         mov     al, _vid_flags
  147.         and     al, _vid_CVIS OR _vid_CACT
  148.         cmp     al, _vid_CVIS OR _vid_CACT
  149.         jne     _crmov1
  150.  
  151.         mov     ah, 2                   ;move cursor function
  152.         mov     bh, _vid_page           ;active page
  153.         mov     dx, _vid_colrow         ;location
  154.         int     10H                     ;execute
  155.  
  156. _crmov1 ret
  157.         ENDP
  158.  
  159. ;========================================
  160. ; Advance the cursor according the last
  161. ; character/string write.
  162.  
  163. CurAdv  PROC    NEAR
  164.         mov     ax, _vid_colrow ;load current location
  165.         add     al, _vid_curadv ;add advance value to column
  166.         call    CurMov          ;move cursor
  167.         ret
  168.         ENDP
  169.  
  170. _video4_end
  171.